So this whole time that we've been learning the Lua language and doing these practice problems, you've
been creating something called algorithms.
A simple definition for an algorithm is a set of instructions for completing a task or solving a problem.
That's all they are.
When you follow recipes in a cookbook to make food, you're following an algorithm.
When you're following the process to insert your keys, start your car and shift into drive.
That's an algorithm.
In this video, I want to briefly talk about what you should focus on when programming in order to efficiently
solve problems and create algorithms.
The very first step before creating an algorithm is to figure out what problem you're trying to solve.
Maybe you want to figure out how to create a guy that plays a click sound when a button is pressed.
Or maybe you want to animate a player's character when they do something like fire a gun.
Whatever it is, the first step you want to do is identify the problem.
The next step is to start outlining possible ways to solve the problem.
And you may not know exactly how to fix it.
Like perhaps you don't know how to execute a block of code when a player clicks on a button.
But all you need to do is make that rough outline that basically says, okay, when a player clicks
this button, I execute a block of code to perform an action based on the button that is clicked.
I may not know how to do that right now, but I do know that I have to do it later.
Once you get all your steps defined, you want to make sure that these steps, these instructions solve
your problem.
If they do, then you'll start researching on how to execute these steps, like research, how to connect
a function to an event, like when a player clicks on a button and so on.
Once you do that, then you start to build your algorithm, start designing it and implementing all
the stuff you learned prior.
Check to make sure that the algorithm is solving your problem and that you're using the right syntax
and that the logical flow makes sense.
Once you finally complete it, then you can start testing your algorithm to see if it works.
And if it doesn't, you can start debugging it to get the algorithm into a state where it's fully working
and solving your problem.
Then the last step is to document your algorithm, write down comments in your scripts, to remind you
and other developers reading the code what a specific part of it is doing that may seem confusing.
Don't ever over comment your code, but do it to where it's concise and doesn't miss any important details.
Now that, my friend, is the basic process of creating algorithms in your code, if you follow these
steps, solving problems you face when making games will be a lot easier.